package cn.ybk.system.service.impl;

import cn.ybk.basic.service.impl.BaseServiceImpl;
import cn.ybk.basic.util.PageList;
import cn.ybk.system.domain.SystemDetail;
import cn.ybk.system.domain.SystemType;
import cn.ybk.system.mapper.SystemDetailMapper;
import cn.ybk.system.query.SystemDetailQuery;
import cn.ybk.system.service.SystemDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SystemDetailServiceImpl implements SystemDetailService {

    @Autowired
    private SystemDetailMapper systemDetailMapper;

    @Override
    public List<SystemDetail> findAll() {
        return systemDetailMapper.findAll();
    }

    @Override
    public SystemDetail findById(Long id) {
        return systemDetailMapper.findById(id);
    }

    @Override
    public void add(SystemDetail systemDetail) {
        systemDetailMapper.add(systemDetail);

    }

    @Override
    public void update(SystemDetail systemDetail) {
        systemDetailMapper.update(systemDetail);

    }

    @Override
    public void delete(Long id) {
        systemDetailMapper.delete(id);
    }

    @Override
    public PageList<SystemDetail> queryByPage(SystemDetailQuery query) {
        Integer totals = systemDetailMapper.queryByCount(query);
        if (totals <= 0){
            return new PageList<>(0,new ArrayList<>());
        }
        final List<SystemDetail> rows = systemDetailMapper.queryByPage(query);

        return new PageList<>(totals,rows);
    }

    @Override
    public void batch(List<Long> ids) {
        systemDetailMapper.batch(ids);
    }

    @Override
    public List<SystemDetail> drawer(Long id) {
        return systemDetailMapper.drawer(id);
    }
}
